// 回放
class videoPlay extends eui.Component{
    private bg:eui.Image;
    private btn_start:eui.Image;
    private btn_speed:eui.Image;
    private btn_replay:eui.Image;
    private moveMc:eui.Group;

    public constructor(){
        super();
        this.once(eui.UIEvent.COMPLETE,this.onComplete,this);
        this.skinName = "src/Game/gameRoom/window/videoPlaySkin.exml";
    }
    private onComplete(){
        this.once(egret.Event.REMOVED_FROM_STAGE,this.onRemove,this);
        StageData.MainObj.addEventListener(Events.STAGE_SIZE,this.updateSize,this);
        this.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick,this);
    }
    private onClick(e:egret.TouchEvent){
        switch(e.target.name){
            case "start":
            if(this.btn_start.source == "video_2_png"){
                this.btn_start.source = "video_1_png";
                this.dispatchEventWith("stop");
            }else{
                this.btn_start.source = "video_2_png";
                this.dispatchEventWith("start");
            }
            StageData.soundObj.soundSinglePlay("click");   
            break;

            case "speed":
            this.dispatchEventWith("speed");
            StageData.soundObj.soundSinglePlay("click");
            break;

            case "replay":
            this.dispatchEventWith("replay");
            StageData.soundObj.soundSinglePlay("click");
            break;
        }
    }
    private updateSize(){
        this.bg.width = StageData.W;
        this.bg.height = StageData.H;
        this.moveMc.x = (this.bg.width-this.moveMc.width)/2;
        this.moveMc.y = this.bg.height-(this.moveMc.height*4);
    }
    private onRemove(){
        StageData.MainObj.removeEventListener(Events.STAGE_SIZE,this.updateSize,this);
        this.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onClick,this);
    }
}